import axios from 'axios'

export function getSession() { //获取session_id
  const url = baseURL + 'ttc.php/Public/verifyInit'
  return axios.post(url).then(res => {
    return res.data;
  })
}

export function sendCaptcha(phone) {//发送短信
  const url = baseURL + '/ttc.php/Public/sendCaptcha'
  return axios.post(url, phone, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function login(data) { //登录
  const url = baseURL + 'ttc.php/Public/login'
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function verify(data) { //文字验证
  const url = baseURL + 'ttc.php/Public/check_verify'
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function isLogin(token) { //判断是否登录过
  const url = baseURL + 'ttc.php/Public/is_login'
  return axios.post(url, {
    "phpsid": localStorage.getItem('token'),
  }, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function isIdentity(data) {//判读是否实名认证
  const url = baseURL + 'ttc.php/Public/is_identity'
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function autIDcard(data) { //上传实名认证
  const url = baseURL + 'ttc.php/User/AutIDcard';
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function defaultContact() { //获取默认联系人
  const url = baseURL + 'ttc.php/User/DefaultContact';
  return axios.post(url, {
    "phpsid": localStorage.getItem('token'),//session_id
  }, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

export function GoodsComplaint(data) { //用户投诉
  const url = baseURL + 'ttc.php/Goods/GoodsComplaint'
  return axios.post(url, data, {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  }).then(res => {
    return res.data;
  })
}

